/*
* © 2010 Autodata Solutions Company. All Rights Reserved
* This source code is the confidential and proprietary information of Autodata Solutions Company.
* The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code
* without the prior written consent of Autodata Solutions Company.
*/
Ext.ns('net.autodata.compare');
(function () {
	var DQ = Ext.DomQuery;
	
	/**
	 * Customized VehiclePanel view to display the BaseVehicle information
	 * @class BaseVehicleView
	 * @extends net.autodata.compare.AbstractVehicleView
	 * @namespace net.autodata.compare
	 */
	var View = Ext.extend(net.autodata.compare.AbstractVehicleView, {
		
		/**
		 * @property
		 * @type Ext.Button
		 */
		compareAnotherButton: undefined,
		
		vehicleInfoCfg: {
			descriptionMaxLength: 30
		},
		
		/**
		 * IOFImage properties
		 * @property imageCfg
		 * @type Object
		 */
		imageCfg: {
			imageWidth: 240,
			imageHeight: 98
			
		},
		
		//override abstract controller to allow creation of this concret class
		constructor: function ()
		{	
			View.superclass.ctor.apply(this, arguments);
		},
		
		/**
		 * @method initTemplates
		 */
		initTemplates: function ()
		{
			var ts = this.templates || {};
			
			if (!ts.mainTpl) {				
				ts.mainTpl = new Ext.Template(					
					'<div class="baseVehicle-view">',
						'<div class="vehiclepanel-header"></div>',
						'<div class="vehiclepanel-body">',
							'<div class="vehicle-info"></div>',				
							'<div class="vehicle-image"></div>',
						'</div>',
					'</div>',
					{
						compiled: true,
						disableFormats: true
					}
				);
			}
						
			this.templates = ts;
			
			View.superclass.initTemplates.apply(this, arguments);
		},
		
		/**
		 * @method initComponents
		 */
		initComponents: function ()
		{
			
			View.superclass.initComponents.apply(this, arguments);
			this.compareAnotherButton = new Ext.Button({
				cls: 'btn-compare-another',
			    text: ASC.message('net.autodata.compare.vehiclepanel.label.compare-another-vehicle'),
				handler: function () {
					this.fireEvent('change');
				},
				scope: this,
				width: Ext.isIE ? undefined : 164
			});
		},
		
		/**
		 * @method render
		 */
		render: function ()
		{
			View.superclass.render.apply(this, arguments);
			
			var body = this.component.el;
			
			this.templates.mainTpl.overwrite(body.dom, {});

			this.vehicleInfo.render(DQ.selectNode('.vehicle-info', body.dom));
			this.vehicleImage.render(DQ.selectNode('.vehicle-image', body.dom));
			this.compareAnotherButton.render(DQ.selectNode('.vehiclepanel-header', body.dom));
		}
	});
	
	
	net.autodata.compare.BaseVehicleView = View;
})();